<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script type="text/javascript" src="<?php echo JS_PATH?>jquery.sgallery.js"></script>
<script>
    function check_form(){
        var tel = $("#tel").val().trim();
        if (tel != '') {
            if (!(/^1[34578]\d{9}$/.test(tel))) {
                $('#file_error_phone').html('手机号码有误,请重输!');
                $('#file_error_phone').show();
                $('#tel').val("");
                $('#tel').focus();
                return false;
            } else {
                $('#file_error_phone').html('');
                $('#file_error_phone').hide();
                return true;
            }
        } else {
            $('#file_error_phone').html('');
            $('#file_error_phone').hide();
            return true;
        }
    }
</script>
<div class="pad-lr-10">
<form name="searchform" action="?m=user_info&c=manage&a=audit_list" method="get" onsubmit="return check_form();">
		<input type="hidden" value=user_info name="m"> 
		<input type="hidden" value="manage" name="c"> 
		<input type="hidden" value="audit_list" name="a">
		<table width="100%" cellspacing="0" class="search-form">
			<tbody>
				<tr>
					<td>
						<div class="explain-col">
							<?php echo L('realname')?>&nbsp;:&nbsp;<input name="audit[name]" class="input-text" value="<?php echo $name?>" type="text" size="25">
							<?php echo L('tel')?>&nbsp;:&nbsp;<input name="audit[tel]" class="input-text" value="<?php echo $search_info['tel']?>" type="text" size="20" id="tel"> <span id="file_error_phone" style="color:red;font-size:10px;"></span>
							&nbsp;&nbsp;&nbsp;<input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit">
							<a style="float:right;cursor:pointer;" href="javascript:;" onclick="refresh_audit('6,16,13')" class="button">刷新数据</a>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</form>
	<!-- 
<form name="myform" action="?m=user_info&c=manage&a=del" method="post" onsubmit="return confirm('<?php echo L('confirm')?>')"> -->
<input type="hidden" value="" name="relation" id="relation">
<div class="table-list">
<table width="100%" cellspacing="0">
	<thead>
		<tr>
			<!-- <th align="center" width="20"><input type="checkbox" value="" id="check_box" onclick="selectalls('id[]');"></th> -->
			<th align="center" width="20">ID</th>
			<th align="center" width="100"><?php echo L('realname')?></th>
			<th align="center" width="100"><?php echo L('user_type')?></th>
			<th align="center" width="80"><?php echo L('gender')?></th>
			<th align="center" width="100"><?php echo L('phone')?></th>
			<th align="center" width="80"><?php echo L('status')?></th>
			<th align="center" width="100"><?php echo L('operation')?></th>
		</tr>
	</thead>
<tbody id="select_id">
<?php
if(!empty($info)){
	foreach($info as $k=>$v) {
?>
    <tr onclick="select_list(this,<?php echo $v['id'];?>)" class="cu">
		<!-- <td align="center"><input type="checkbox" class="inputcheckbox" value="<?php echo $v['id']?>" name="id[]" ></td> -->
		<td align="center"><?php echo $v['id']?></td>
		<td align="center"><?php echo $v['name']?$v['name']:'<font color="red">（未设置）</font>';?></td>
		<td align="center"><?php if($v['user_type']==1){echo "普通用户";}elseif($v['user_type']==2){echo "模特";}elseif($v['user_type']==3){echo "经纪人";}elseif($v['user_type']==4){echo "商户";}else{echo '<font color="red">（未设置）</font>';}?></td>
		<td align="center"><?php if($v['gender']==1){echo "男";}elseif ($v['gender']==2){echo "女";}else{echo "保密";}?></td>
		<td align="center"><?php echo $v['tel']?$v['tel']:'<font color="red">（未设置）</font>';?></td>
		<td align="center"><?php if($v['status']==1){echo "<span style='color:blue;font-weight:bolder;'>待审核</span>";}elseif ($v['status']==2){echo '<span style="color:red;font-weight:bolder;">驳回</span>';}elseif($v['status'] == 3){echo '<span style="color:green;font-weight:bolder;">通过</span>';}?></td>
		<td align="center">
		<a href="?m=user_info&c=manage&a=audit_detail&id=<?php echo $v['id']?>"><?php echo L('detail');?></a>
		<?php if($v['status']==2 || $v['status']==3){?>
		<?php }else{?>
		&nbsp;|&nbsp;
		<a href="?m=user_info&c=manage&a=check_log&id=<?php echo $v['id']?>&name=<?php echo $v['name']?>&check_status=3&created_by=<?php echo $v['created_by']?>"><?php echo L('pass')?></a>
		&nbsp;|&nbsp;
		<a href="?m=user_info&c=manage&a=check_log&id=<?php echo $v['id']?>&name=<?php echo $v['name']?>&check_status=2&created_by=<?php echo $v['created_by']?>"><?php echo L('reject')?></a>
		<?php }?>
		</td>
    </tr>
<?php
	}
} else {
?>
	<tr><td colspan='11' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>
<?php }?>
</tbody>
</table>
<div id="pages"><?php echo $pages?></div>
</div>
<!-- </form> -->
</div>
<script type="text/javascript">
// function check_log(id,name,check_status){
// 	var check_id = $("#relation").val();
// 	if(id.length==0 && check_id.length==0){
// 		alert("请勾选需要审核的内容！");
// 		return false;
// 	}
// 	if(id.length==0){
// 		var id=$("#relation").val();
// 	}
// 	window.top.art.dialog({id:'check'}).close();
// 	window.top.art.dialog({
//		title:'<?php echo L('audit')?> '+name+' ',id:'check',iframe:'?m=user_info&c=manage&a=check_log&id='+id+'&check_status='+check_status,width:'700',height:'450'}, 
// 		function(){var d = window.top.art.dialog({id:'check'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, 		function(){window.top.art.dialog({id:'check'}).close()}
// 	);
// }
function selectalls(name) {
	//alert($('#select_id tr .inputcheckbox').length);
	var objs = $('#select_id tr .inputcheckbox');
	var strs = '';
	if ($("#check_box").attr("checked")=='checked') {
		$("input[name='"+name+"']").each(function() {
  			$(this).attr("checked","checked");
  			
			$('#select_id tr').attr('class','line_ff9966');
		});
		for(var i=0; i<objs.length; i++){
			if (i == 0) {
				if(objs[i].checked) strs = objs[i].value;
			} else {
				if(objs[i].checked) strs +='|' + objs[i].value;
			}
		}
		$('#relation').val(strs);
	} else {
		$("input[name='"+name+"']").each(function() {
  			$(this).removeAttr("checked");
  			$('#select_id tr').attr('class','line_fbffe4')
  			$('#relation').val('');
		});
	}
}
function select_list(obj,id) {
	var relation_ids =$('#relation').val();
	if($(obj).attr('class')=='line_ff9966' || $(obj).attr('class')==null) {
		$(obj).attr('class','line_fbffe4');
		$(obj).find('.inputcheckbox').removeAttr("checked");
		if(relation_ids !='' ) {
			var r_arr = relation_ids.split('|');
			var newrelation_ids = '';
			$.each(r_arr, function(i, n){
				if(n!=id) {
					if(i==0) {
						newrelation_ids = n;
					} else {
					 newrelation_ids = newrelation_ids+'|'+n;
					}
				}
			});
			$('#relation').val(newrelation_ids);
		}
	} else {
		$(obj).attr('class','line_ff9966');
		$(obj).find('.inputcheckbox').attr("checked","checked");
		if(relation_ids =='' ) {
			$('#relation').val(id);
		} else {
			relation_ids = relation_ids+'|'+id;
			$('#relation').val(relation_ids);
		}
	}
}
function refresh_audit(type){
	var type_arr = type;
	$.ajax({
		type:"POST",
		async:false,
		url:"?m=user_info&c=manage&a=refresh_cache&pc_hash=<?php echo $_SESSION['pc_hash']?>",
		data:{"type":type_arr},
		dataType:"JSON",
		success:function(result){
			alert(result.msg);
		}
	});
}
</script>
</body>
</html>